import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { HolderVO, HolderForm, HolderQuery } from '@/api/credit/holder/types';

/**
 * 查询信用卡持卡人列列表
 * @param query
 * @returns {*}
 */

export const listHolder = (query?: HolderQuery): AxiosPromise<HolderVO[]> => {
  return request({
    url: '/credit/holder/list',
    method: 'get',
    params: query
  });
};


export const listNoPageHolder = (query?: HolderQuery): AxiosPromise<HolderVO[]> => {
  return request({
    url: '/credit/holder/noPage/list',
    method: 'get',
    params: query
  });
};


/**
 * 查询信用卡持卡人列详细
 * @param id
 */
export const getHolder = (id: number | string): AxiosPromise<HolderVO> => {
  return request({
    url: '/credit/holder/' + id,
    method: 'get'
  });
};

/**
 * 新增信用卡持卡人列
 * @param data
 */
export const addHolder = (data: HolderForm) => {
  return request({
    url: '/credit/holder',
    method: 'post',
    data: data
  });
};

/**
 * 修改信用卡持卡人列
 * @param data
 */
export const updateHolder = (data: HolderForm) => {
  return request({
    url: '/credit/holder',
    method: 'put',
    data: data
  });
};

/**
 * 删除信用卡持卡人列
 * @param id
 */
export const delHolder = (id: string | number | Array<string | number>) => {
  return request({
    url: '/credit/holder/' + id,
    method: 'delete'
  });
};
